<!--
 * @Author: wuyang
 * @Description: 
 * @Date: 2023-01-03 14:27:11
 * @LastEditors: wuyang
 * @LastEditTime: 2023-01-04 13:50:53
 * @FilePath: \vue-ts-vite\src\components\svgIcon\index.vue
-->

<script setup lang="ts">
import { computed } from "vue";

const props = defineProps({
  iconClass: {
    type: String,
    required: true,
  },
  className: {
    type: String,
    default: "",
  },
  iconColor: {
    type: String,
    default: "CurrentColor",
  },
});
const iconName = computed(() => `#icon-${props.iconClass}`);
const svgClass = computed(() => {
  if (props.className) {
    return "svg-icon " + props.className;
  } else {
    return "svg-icon";
  }
});
</script>
<template>
  <svg :class="svgClass" aria-hidden="true" :fill="iconColor">
    <use :xlink:href="iconName" />
    <!-- 使用实例 -->
    <!-- <svg-icon icon-class="header-down" /> -->
  </svg>
</template>
 
<style scoped>
.svg-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  overflow: hidden;
}
</style>